﻿using System;
using System.Windows.Data;
using System.Windows.Media;

namespace BingSpatialDataServiceExcelAddin.Views.Converters
{
    public class StatusConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            if (value != null)
            {
                if (value is bool)
                {
                    return (bool)value ? new SolidColorBrush(Colors.Green) : new SolidColorBrush(Colors.Red);
                }
                else if (value is string)
                {
                    if (!string.IsNullOrWhiteSpace(value as string))
                    {
                        switch (value as string)
                        {
                            case "Completed":
                                return new SolidColorBrush(Colors.Green);
                            case "Pending":
                                return new SolidColorBrush(Colors.Yellow);
                            default:
                                return new SolidColorBrush(Colors.Red);
                        }
                    }
                }
            }

            return null;
        }

        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }
}
